﻿using Inventory.API.Application.Command.WarehouseManagementCommand;
using Inventory.API.Application.Command.ZonemanagementCommand;
using Inventory.Domain;
using Inventory.Errorcode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Inventory.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ZonemanagementController : ControllerBase
    {

        private readonly IMediator _mediator;
      /// <summary>
      /// 构造函数
      /// </summary>
      /// <param name="mediator"></param>
        public ZonemanagementController(IMediator mediator)
        {
            _mediator = mediator;
        }

         /// <summary>
         /// 新增仓区
         /// </summary>
         /// <param name="command"></param>
         /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddZonemanagement(AddZonemanagementCommand command)
        {
            return await _mediator.Send(command);
        }
         /// <summary>
         /// 获取仓区列表
         /// </summary>
         /// <param name="command"></param>
         /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult> GetZonemanagementList([FromQuery] GetZonemanagementListQueryCommand command)
        {
            return await _mediator.Send(command);
        }
            /// <summary>
            /// 删除库区
            /// </summary>
            /// <param name="command"></param>
            /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteZonemanagement([FromQuery] DeleteZonemanagementCommand command)
        {
            return await _mediator.Send(command);
        }

     /// <summary>
     /// 显示库区详情
     /// </summary>
     /// <param name="query"></param>
     /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<Zonemanagement>> GetZonemanagementInfo([FromQuery] GeZonemanagementfoCommand query)
        {
            return await _mediator.Send(query);
        }
     

        /// <summary>
        /// 更新库区信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateZonemanagement(UpdateZonemanagementCommand command)
        {
            return await _mediator.Send(command);
        }


    }
}
